﻿Imports System.ComponentModel


Public Class CTCorridaIntermediario
  


Private _Intermediario          As CTParamIntermediario
Private _MontoOperado           As Decimal

Private _PorcentActualOperado   As Decimal
Private _PorcentDiferencia      As Decimal
Private _MontoDisponible        As Decimal
Private _NombreIntermediario    As String 

Private  _MontoTotal            As Decimal 





 



Public sub new (ByRef Intermediario As CTParamIntermediario, ByVal pMontoOperadoA As Decimal, ByVal pMontoTotal As Decimal)

   _Intermediario = Intermediario
   _MontoOperado = pMontoOperadoA
   _MontoTotal  = pMontoTotal 
   _NombreIntermediario  = _Intermediario.NombreIntermediario 

End Sub


Default ReadOnly  Property Columna(ByVal index As Integer) As Object
    Get
        
         Select Case index 

                Case 0
                    Return  NombreIntermediario 
                Case 1
                    Return MontoOperado 
                Case 2
                    Return PorcentActualOperado 
                Case 3
                    Return PorcentDiferencia 
                Case 4
                    Return MontoDisponible                 
                Case ELSE
                    Return ""
             End Select

    End Get

End Property

 

Public Property Intermediario() As CTParamIntermediario
    Get
        Return _Intermediario
    End Get
    Set(ByVal value As CTParamIntermediario)
        _Intermediario = value
        _NombreIntermediario = _Intermediario.NombreIntermediario 
    End Set
End Property


Public Property NombreIntermediario() As String
    Get
        Return _NombreIntermediario 
    End Get
    Set(ByVal value As String)
        _NombreIntermediario = value
    End Set
End Property


Public   Property MontoOperado() As Decimal
    Get
        Return _MontoOperado
    End Get

    Set(value As Decimal )
        _MontoOperado = value  
    End Set
    
End Property


Public Property PorcentActualOperado() As Decimal 
    Get
             If _MontoTotal <> 0 then 
                _PorcentActualOperado = ((_MontoOperado / _MontoTotal ) * 100)
                Return   decimal.Round (_PorcentActualOperado,2)
             Else
               Return 0
             End If
    End Get
    
    Set(ByVal value As Decimal)
        _PorcentActualOperado = value
    End Set
End Property


Public Property PorcentDiferencia() As decimal
    Get

            If _MontoTotal <> 0 then    
                _PorcentDiferencia  = (Intermediario.NivelMaxDistrib  -   ( (_MontoOperado / _MontoTotal ) * 100))            
                Return  Decimal.Round(_PorcentDiferencia, 2)
             Else
               Return 0
             End If


    End Get
    Set(ByVal value As Decimal )
        _PorcentDiferencia = value
    End Set
End Property


Public Property MontoDisponible() As Decimal
    Get
       
        _MontoDisponible = Decimal.Round ( ( _MontoTotal * (_PorcentDiferencia/100)) , 2)
        Return  _MontoDisponible
      
    End Get
    Set(ByVal value As Decimal)
        _MontoDisponible = value
      
    End Set
End Property


End Class
